package com.AKBAL34.android.Androidmind;

import android.app.Activity;
import android.os.Bundle;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

public class TextPlay extends Activity {

	Button check;
	ToggleButton passtog;
	EditText input;
	TextView display;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.text);
		
		BaconEggs();
		
		passtog.setOnClickListener(new View.OnClickListener() {

			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (passtog.isChecked()) {
					input.setInputType(InputType.TYPE_CLASS_TEXT
							| InputType.TYPE_TEXT_VARIATION_PASSWORD);
				} else {
					input.setInputType(InputType.TYPE_CLASS_TEXT);
				}
			}
		});

		check.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				String codigo = input.getText().toString();
				if (codigo.contentEquals("left")) {
						display.setGravity(Gravity.LEFT);
				}
				else if (codigo.contentEquals("center")) {
					display.setGravity(Gravity.CENTER);
				}
				else if (codigo.contentEquals("right")) {
					display.setGravity(Gravity.RIGHT);
				}

			}
		});

	}

	private void BaconEggs() {
		// TODO Auto-generated method stub
		check = (Button) findViewById(R.id.resultado);
		passtog = (ToggleButton) findViewById(R.id.toggleButton1);
		input = (EditText) findViewById(R.id.commad);
		display = (TextView) findViewById(R.id.tresultado);

	}

}
